package br.ufrn.dca.controlelrl;


public class Seguidor {
	
    private double erroTotal = 0;
    private double h = 0.001;
    private double KS1,
                    KS2,
                    KS3;
    private double P1Real,
                P2Real,
                P3Real,
                P1Img,
                P2Img,
                P3Img;
    
	public Seguidor() {
	}
	
	public Seguidor(double p1Real, double p2Real, double p3Real, double p1Img,
			double p2Img, double p3Img) {
		P1Real = p1Real;
		P2Real = p2Real;
		P3Real = p3Real;
		P1Img = p1Img;
		P2Img = p2Img;
		P3Img = p3Img;
	}

	public Seguidor(double kS1, double kS2, double kS3) {
		KS1 = kS1;
		KS2 = kS2;
		KS3 = kS3;
	}

	public double seguidorRef(double erro2,double T1,double T2){
        
        double saida;
        erroTotal += erro2;
        saida = erroTotal*getKS1()*h - ((getKS2() * T1) + (getKS3() * T2));
        return saida;
     }
     
    public void calcularGanhos() {
	        
	    Double a = (getP1Real() + getP2Real() + getP3Real()) * -1;
	    Double b = getP1Real() * getP2Real() + (getP1Img()) * (getP1Img()) + (getP1Real() + getP2Real()) * getP3Real();
	    Double c = ((getP1Real() * getP2Real() + (getP1Img()) * (getP1Img())) * getP3Real()) * -1;
	    setKS2(2.55818 * a - 4.77274 * b + 8.90436 * c + 30.6288);
	    setKS1(1133.3845 * a - 2114.5234 * b - 5383.35185 * c + 4360.5058);
	    setKS3(3255.2083 * a + 3255.2083 * b + 3255.2083 * c + 3255.2083);
    }

	public double getErroTotal() {
		return erroTotal;
	}

	public void setErroTotal(double erroTotal) {
		this.erroTotal = erroTotal;
	}

	public double getH() {
		return h;
	}

	public void setH(double h) {
		this.h = h;
	}

	public double getKS1() {
		return KS1;
	}

	public void setKS1(double kS1) {
		KS1 = kS1;
	}

	public double getKS2() {
		return KS2;
	}

	public void setKS2(double kS2) {
		KS2 = kS2;
	}

	public double getKS3() {
		return KS3;
	}

	public void setKS3(double kS3) {
		KS3 = kS3;
	}

	public double getP1Real() {
		return P1Real;
	}

	public void setP1Real(double p1Real) {
		P1Real = p1Real;
	}

	public double getP2Real() {
		return P2Real;
	}

	public void setP2Real(double p2Real) {
		P2Real = p2Real;
	}

	public double getP3Real() {
		return P3Real;
	}

	public void setP3Real(double p3Real) {
		P3Real = p3Real;
	}

	public double getP1Img() {
		return P1Img;
	}

	public void setP1Img(double p1Img) {
		P1Img = p1Img;
	}

	public double getP2Img() {
		return P2Img;
	}

	public void setP2Img(double p2Img) {
		P2Img = p2Img;
	}

	public double getP3Img() {
		return P3Img;
	}

	public void setP3Img(double p3Img) {
		P3Img = p3Img;
	}

}
